package com.wn.ziroom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wn.ziroom.entity.Cities;
import com.wn.ziroom.entity.Provinces;
import com.wn.ziroom.mapper.CitiesMapper;
import com.wn.ziroom.service.CitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-23 02:27:54
 */
@Service
public class CitiesServiceImpl extends ServiceImpl<CitiesMapper, Cities> implements CitiesService {

    private CitiesMapper citiesMapper;

    @Autowired
    public void setCitiesMapper(CitiesMapper citiesMapper) {
        this.citiesMapper = citiesMapper;
    }

    @Override
    public List<Cities> findListByCode(String code) {
        QueryWrapper<Cities> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("provinceCode",code);

        return citiesMapper.selectList(queryWrapper);
    }

    @Override
    public Cities findCityByName(String cityName) {
        QueryWrapper<Cities> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name",cityName);

        return citiesMapper.selectOne(queryWrapper);
    }
}
